﻿using System;
using System.Linq;
using System.Reflection;

namespace ProjectEuler.Extensions
{
    internal static class CustomAttributeProviderExtensions
    {
        public static T[] GetCustomAttributes<T>(this ICustomAttributeProvider provider, Boolean inherit)
            where T : Attribute
        {
            return provider.GetCustomAttributes(typeof(T), inherit).Cast<T>().ToArray();
        }

        public static T GetCustomAttribute<T>(this ICustomAttributeProvider provider, Boolean inherit)
            where T : Attribute
        {
            return provider.GetCustomAttributes<T>(inherit).FirstOrDefault();
        }
    }
}